﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Einstein.Platform.Window;

namespace Einstein.Platform
{
    public class WinManager
    {
        public static Dictionary<string, Form> WinList = new Dictionary<string, Form>();
        /// <summary>
        /// 显示一个多文档子窗口
        /// </summary>
        /// <param name="childWin"></param>
        /// <param name="parentWin"></param>
        public static void Show(Form childWin, Form parentWin)
        {
            if (WinList.ContainsKey(childWin.Name))
            {
                Form Win =WinList[childWin.Name];
                if (Win != null)
                {
                    Win.Close();
                    WinList.Remove(childWin.Name);
                }
            }
            childWin.MdiParent = parentWin;
            childWin.WindowState = FormWindowState.Maximized;
            childWin.Show();
            childWin.Update();
            WinManager.WinList[childWin.Name] =childWin;
        }
    }
}